package com.bff.gaia.mix.api.xjoin.client.hbase.core.table;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.bff.gaia.mix.api.xjoin.core.side.SideTableInfo;

import java.util.List;
import java.util.Map;

public class HbaseSideTableInfo extends SideTableInfo {
	private static final String CURR_TYPE = "hbase";

	private String host;

	private String port;

	private String family;

	private String[] rowkey;

	/**
	 * 是否根据rowkey前缀查询
	 */
	private boolean preRowKey = false;


	/**
	 * 是否根据qualifier进行查询
	 */
	private boolean qualifierQuery = false;

	private Map<String, String> columnNameFamily;

	private String tableName;

	private String[] columnRealNames;

	private List<String> columnRealNameList = Lists.newArrayList();

	private Map<String, String> aliasNameRef = Maps.newHashMap();


	public HbaseSideTableInfo() {
		setType(CURR_TYPE);
	}


	@Override
	public boolean check() {
		return false;
	}

	public String getHost() {
		return host;
	}

	public void setHost(String host) {
		this.host = host;
	}

	public String getPort() {
		return port;
	}

	public void setPort(String port) {
		this.port = port;
	}

	public String getFamily() {
		return family;
	}

	public void setFamily(String family) {
		this.family = family;
	}

	public String[] getRowkey() {
		return rowkey;
	}

	public void setRowkey(String[] rowkey) {
		this.rowkey = rowkey;
	}

	public Map<String, String> getColumnNameFamily() {
		return columnNameFamily;
	}

	public void setColumnNameFamily(Map<String, String> columnNameFamily) {
		this.columnNameFamily = columnNameFamily;
	}

	public String getTableName() {
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	public void putAliasNameRef(String aliasName, String hbaseField) {
		aliasNameRef.put(aliasName, hbaseField);
	}

	public Map<String, String> getAliasNameRef() {
		return aliasNameRef;
	}

	public String getHbaseField(String fieldAlias) {
		return aliasNameRef.get(fieldAlias);
	}

	public String[] getColumnRealNames() {
		return columnRealNames;
	}

	public void setColumnRealNames(String[] columnRealNames) {
		this.columnRealNames = columnRealNames;
	}

	public void addColumnRealName(String realName) {
		this.columnRealNameList.add(realName);
	}

	public boolean isPreRowKey() {
		return preRowKey;
	}

	public void setPreRowKey(boolean preRowKey) {
		this.preRowKey = preRowKey;
	}

	public boolean isQualifierQuery() {
		return qualifierQuery;
	}

	public void setQualifierQuery(boolean qualifierQuery) {
		this.qualifierQuery = qualifierQuery;
	}

	@Override
	public void finish() {
		super.finish();
		this.columnRealNames = columnRealNameList.toArray(new String[columnRealNameList.size()]);
	}
}